
import json
from loguru import logger
from app.core.conf import ST

from sio_agv.agv_socket import AGV
from sche_task.agv import register_agv_event


async def get_agv_map(map_type:str):
    if map_type == 'cache':
        with open(ST.AGV_MAP_PATH,'r',encoding='utf-8') as f:
            data = json.load(f)
            return data
    else:
        tt15 = AGV.get_agv(ST.AGV_IP)
        tt15.send('status',1,1300)
        map_info = tt15.receive('status')
        # 然后根据地图的名字去查询地图数据 
        tt15.send('config',1, 4011,{"map_name":map_info['current_map']})
        map_data = tt15.receive('config')
        return map_data





async def start_agv_task():
    """启动AGV定时连接计划
    """
    register_agv_event()